<template>
  <div>
    <el-card class="box-card">
      <el-breadcrumb separator="/">
        <el-breadcrumb-item :to="{ path: '/home' }">首页</el-breadcrumb-item>
        <el-breadcrumb-item>权限管理</el-breadcrumb-item>
        <el-breadcrumb-item>权限列表</el-breadcrumb-item>
      </el-breadcrumb>

      <el-table :data="tableData" border class="tabletop" height="380">
        <el-table-column type="index" label="序号"></el-table-column>
        <el-table-column label="权限名称" prop="authName"></el-table-column>
        <el-table-column label="路径" prop="path"></el-table-column>
        <el-table-column label="权限级别">
          <template slot-scope="scope">
            <el-tag v-if="scope.row.level==0" >一级</el-tag>
            <el-tag v-if="scope.row.level==1" type="success">二级</el-tag>
            <el-tag v-if="scope.row.level==2" type="warning">三级</el-tag>
          </template>
        </el-table-column>
      </el-table>
    </el-card>
  </div>
</template>

<script>
export default {
  name: "rights",
  data() {
    return {
      // 定义表格初始化数据属性
      tableData: []
    };
  },
  methods: {
    //查询所有权限,显示权限列表
    async query() {
      let rst = await this.$http.get("/rights/list");
      if (rst.meta.status == 200) {
        //将查询结果赋值给tableData
        this.tableData = rst.data;
      } else {
        this.$message.error("权限列表获取失败");
      }
      console.log(rst);
    }
  },
  mounted() {
    // 调用query方法
    this.query();
  }
};
</script>

<style>
</style>